package is.ru.honn.rumblr.service;

import is.ru.honn.rumblr.domain.AbstractRumblrPost;
import is.ru.honn.rumblr.domain.RumblrPost;
import is.ru.honn.rumblr.domain.User;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class PostServiceStub implements PostService
{
  List<RumblrPost> posts = new ArrayList<RumblrPost>();
  protected User user;
  protected StatisticsStrategy statisticsStrategy;

  public User getUser()
  {
    return user;
  }

  public void setUser(User user)
  {
    this.user = user;
  }

  public void printSummary()
  {
    System.out.println(statisticsStrategy.getSummary());
  }

  public void addPost(RumblrPost post)
  {
    posts.add(post);
    statisticsStrategy.count((AbstractRumblrPost)post);
  }

  public void setStatisticsStrategy(StatisticsStrategy strategy)
  {
    this.statisticsStrategy = strategy;
  }

  public Collection<RumblrPost> getPosts(String username)
  {
    return posts;
  }
}
